home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 132_01 / bdscio.h < prev    next >
Text File  |  1985-08-19  |  6KB  |  148 lines

  1. /*
  2.     The BDS C Standard I/O header file --  v1.41    October 14, 1980
  3.  
  4.     This file contains global definitions, for use in all C programs
  5.     in PLACE of (yechhh) CONSTANTS. Characteristics of your system such
  6.     as video screen size, interface port numbers and masks, buffered I/O
  7.     allocations, etc., should all be configured just once within this
  8.     file. Any program which needs them should contain the preprocessor
  9.     directive:
  10.  
  11.         #include "bdscio.h"
  12.  
  13.     near the beginning. 
  14.     Go through and set all this stuff as soon as you get the package,
  15.     and most terminal-dependent sample programs should run much better.
  16.     Some games (such as STONE.C and RALLY.C), which were contributed and
  17.     beyond the scope of my ablity (or patience) to generalize, may not
  18.     bother to use the globals from this file, alas.
  19.  
  20. */
  21.  
  22.  
  23. /*******   Some console (video) terminal characteristics:   *******/
  24.  
  25. #define TWIDTH    80    /* # of columns    */
  26. #define TLENGTH    24    /* # of lines    */
  27.  
  28. #define CSTAT    0    /* Console status port    */
  29. #define CDATA 1        /* Console data port    */
  30. #define CIMASK    0x40    /* Console input data ready mask   */
  31. #define COMASK    0x80    /* Console output data ready mask  */
  32. #define CAHI    1    /* True if console status active high    */
  33. #define CRESET    0    /* True if status port needs to be reset  */
  34. #define CRESETVAL 0    /* If CRESET is true, this is the value to send    */
  35.  
  36. #define CLEARS    "\033E"    /* String to clear screen on console    */
  37. #define INTOREV    "\033p"    /* String to switch console into reverse video    */
  38. #define OUTAREV "\033q"    /* String to switch console OUT of reverse video  */
  39. #define CURSOROFF "\033x5"    /* String to turn cursor off    */
  40. #define CURSORON "\033y5"    /* String to turn cursor on    */
  41.  
  42. #define ESC    '\033'    /* Standard ASCII 'escape' character    */
  43.  
  44.  
  45. /*****      Modem characteristics:      *****/
  46.  
  47. #define    MSTAT    2    /* Modem status port    */
  48. #define MDATA    3    /* Modem data port    */
  49. #define MIMASK    0x40    /* Modem input data ready mask    */
  50. #define MOMASK    0x80    /* Modem ready to send a character mask    */
  51. #define MAHI    1    /* True if modem status logic active high  */
  52. #define MRESET    0    /* True if modem status port needs to be reset */
  53. #define MRESETVAL 0    /* If MRESET true, this is the byte to send */
  54.  
  55.  
  56. /******    General purpose Symbolic constants:  *********/
  57.  
  58. #define BASE 0        /* Base of CP/M system RAM (0 or 0x4200)  */
  59. #define NULL 0        /* Used by some functions to indicate zilch */
  60. #define EOF -1        /* Physical EOF returned by low level I/O functions */
  61. #define ERROR -1    /* General "on error" return value */
  62. #define OK 0        /* General purpose "no error" return value */
  63. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker (sometimes!)  */
  64. #define SECSIZ 128    /* Sector size for CP/M read/write calls */
  65. #define MAXLINE 135    /* Longest line of input expected from the console */
  66. #define TRUE 1        /* general purpose true truth value    */
  67. #define FALSE 0        /* general purpose false truth value     */
  68.  
  69. /*******   Number of sectors to use for buffered I/O: ***********
  70.    The NSECTS symbol controls the compilation of the buffered
  71.    I/O routines within STDLIB2.C, allowing each user to set the
  72.    buffer size most convenient for his system, while keeping
  73.    the numbers totally invisible to the C source programs using
  74.    buffered I/O (via the BUFSIZ defined symbol.) For larger
  75.    NSECTS, the disk I/O is faster...but more ram is taken up.
  76.    Note that prior (pre 1.4) versions of the library functions
  77.    were not set up to support this customizable buffer size,
  78.    and always compiled as if NSECTS was 1 in this version. To
  79.    change the buffer size allocation, follow these steps:
  80.  
  81.      1) Alter NSECTS to the desired value here in bdscio.h
  82.      2) Re-compile STDLIB1.C and STDLIB2.C
  83.      3) Use CLIB to combine STDLIB1.CRL and STDLIB2.CRL to make
  84.       a new DEFF.CRL.
  85.  
  86.    Make sure you use declare all your I/O buffers with the a
  87.    statement such as:
  88.           char buf_name[BUFSIZ];
  89.        instead of the older and now obsolete:
  90.           char buf_name[134];
  91.        (and always #include "bdscio.h" in your programs!)
  92.  ****************************************************************/
  93.  
  94. #define NSECTS 8    /* Number of sectors to buffer up in ram */
  95.  
  96. #define BUFSIZ (NSECTS * SECSIZ + 6 )    /* Don't touch this */
  97.  
  98. struct _buf {                /* Or this...        */
  99.     int _fd;
  100.     int _nleft;
  101.     char *_nextp;
  102.     char _buff[NSECTS * SECSIZ];
  103. };
  104.  
  105.  
  106.  
  107. /****************************************************************************
  108.     If you plan to use the high-level storage allocation functions
  109.     from the library ("alloc" and "free") then:
  110.  
  111.       1) Uncomment (enable) the "ALLOC_ON" definition, and comment out the
  112.          "ALLOC_OFF" definition from this file.
  113.  
  114.       2) Re-compile STDLIB1.C, and use CLIB to transfer "alloc"
  115.          and "free" into the DEFF.CRL library file.
  116.  
  117.       3) THIS IS IMPORTANT!!! Include the statement:
  118.  
  119.         _allocp = NULL;       /* initialize allocation pointer */
  120.  
  121.          somewhere in your "main" function PRIOR to the first use
  122.          of the "alloc" function. DON'T FORGET THIS INITIALIZATION!!
  123.  
  124.     Remember to include bdscio.h in ALL files of your C program.
  125.  
  126.     The lack of static variables is the reason for all this messiness.
  127.  ****************************************************************************/
  128.  
  129. #define ALLOC_OFF 1    /* disables storage allocation if uncommented */
  130.  
  131.             /* only ONE of these two lines should be uncommented */
  132. /*
  133. #define ALLOC_ON 1    /* enables storgage allocation if uncommented */
  134. */
  135.  
  136.  
  137. #ifdef ALLOC_ON            /* if storage allocation enabled, */
  138.  
  139. struct _header  {
  140.     struct _header *_ptr;
  141.     unsigned _size;
  142.  };
  143.  
  144. struct _header _base;        /* declare this external data to  */
  145. struct _header *_allocp;    /* be used by alloc() and free()  */
  146.  
  147. #endif
  148.